package org.testis.gui.mvc.utilities;

import java.io.IOException;
import java.io.PrintStream;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.grlea.log.SimpleLog;
import org.grlea.log.SimpleLogger;


/**
 *
 * @author nurhat
 */
public class DebugLogger extends PrintStream
{

    private static SimpleLog logConf = null;
    private static SimpleLogger log = null;
    private static DebugLogger m_DebugLogger = null;


    private DebugLogger()
    {


        super(System.out,
              true);
        try {
             java.net.URL url = ClassLoader.getSystemResource("com/airties/atof/gui/simplelogger/simplelog.properties");

            logConf =
                new SimpleLog(url);
            log =
                new SimpleLogger(logConf,
                                 DebugLogger.class);
        } catch (IOException ex) {
            Logger.getLogger(DebugLogger.class.getName()).
                log(Level.SEVERE,
                    null,
                    ex);
        }
    }


    public static DebugLogger getInstance()
    {
        if (m_DebugLogger == null) {
            m_DebugLogger = new DebugLogger();
        }
        return m_DebugLogger;
    }


    @Override
    public void print(boolean b)
    {
        super.print(b);
    }


    @Override
    public void print(Object obj)
    {
        log.debug(obj.toString());
    }


    @Override
    public void print(String s)
    {
        log.debug(s);
    }


    @Override
    public void println(String s)
    {
        log.debug(s);
    }


    @Override
    public void println(Object obj)
    {
        log.debug(obj.toString());
    }
}